package com.xzk.pagemoduleapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.github.clans.fab.FloatingActionButton;
import com.github.clans.fab.FloatingActionMenu;
import com.sonnyjack.widget.dragview.SonnyJackDragView;
import com.utils.DragFrameLayout;

public class MainActivity extends AppCompatActivity {

    private ImageView dragImg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initDrag();
    }

    private void initDrag(){

//        ImageView imageView = new ImageView(this);
//        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
//        imageView.setImageResource(R.mipmap.ic_launcher_round);
//        imageView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//                Toast.makeText(MainActivity.this, "点击了...", Toast.LENGTH_SHORT).show();
//            }
//        });
        View inflate = LayoutInflater.from(this).inflate(R.layout.util_drag_view, null);

        SonnyJackDragView sonnyJackDragView = new SonnyJackDragView.Builder()
                .setActivity(this)//当前Activity，不可为空
                .setDefaultLeft(30)//初始位置左边距
                .setDefaultTop(30)//初始位置上边距
                .setNeedNearEdge(false)//拖动停止后，是否移到边沿
                .setSize(100)//DragView大小
                .setView(inflate)//设置自定义的DragView，切记不可为空
                .build();


//        boolean needNearEdge = sonnyJackDragView.getNeedNearEdge();
//        sonnyJackDragView.setNeedNearEdge(!needNearEdge);

//        dragImg = (ImageView)findViewById(R.id.dragImg);
//        DragFrameLayout frameLayout = (DragFrameLayout)findViewById(R.id.becausefloat);
//        frameLayout.setDragImageListener(new DragFrameLayout.DragImageClickListener() {
//
//            private boolean isDaix;
//
//            @Override
//            public void onClick() {
//                // TODO Auto-generated method stub
//                if (isDaix) {
//                    dragImg.setBackgroundResource(R.drawable.ic_launcher_foreground);
//                    isDaix = false;
//                } else {
//                    dragImg.setBackgroundResource(R.drawable.ic_launcher_background);
//                    isDaix = true;
//                }
//                Toast.makeText(MainActivity.this, "点击",
//                        Toast.LENGTH_LONG).show();
//            }
//        });
    }

}
